package gui;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.RenderingHints;
import javax.swing.JLabel;

/**
 * @author Ramy Refky 
 * */
public class DFFComponentLabel extends ComponentLabel{

	private static final long serialVersionUID = 1L;
	
	JLabel DFFLabel;
	
	/**
	 * Constructor initializes ComponentLabel.
	 * @param XLocation, YLocation, Width, Height
	 */
	public DFFComponentLabel(int xLoc,int yLoc,int originalWidth, int originalHeight){
		super(xLoc,yLoc,originalWidth,originalHeight);

		DFFLabel = new JLabel("D-FF");
		DFFLabel.setBounds(newWidth/2-12,newHeight/3,25,10);
		add(DFFLabel);
		
		repaint();
	}
	@Override
	public void zoomAdjust(Double zoomFactor){
		newWidth=(int) (originalWidth*zoomFactor);
		newHeight=(int) (originalHeight*zoomFactor);
		setBounds(0,0,newWidth,newHeight);
		DFFLabel.setBounds(newWidth/2-12,newHeight/3,25,10);
		repaint();
	}
	protected void paintComponent(Graphics g) {
		super.paintComponent(g);

		Rectangle Box = new Rectangle();
		Box.setBounds(newWidth/6,2,newWidth*2/3,newHeight-4);
		
    	Graphics2D g2 = (Graphics2D)g;
    	g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                             RenderingHints.VALUE_ANTIALIAS_ON);
    	
        g2.setStroke(new BasicStroke(2f)); 
        g2.setPaint(Color.black);
        g2.draw(Box);
        
        if(!selected)
        	g2.setPaint(Color.white);
        else
        	g2.setPaint(Color.getHSBColor((float)0.5,(float)0.1,(float)0.9));
        Box.setBounds(newWidth/6+1,3,newWidth*2/3-1,newHeight-5);
        
        g2.fill(Box);
        
        g2.setPaint(Color.black);
        g2.drawLine(newWidth/6+1,newHeight*3/4-4,newWidth/6+7,newHeight*3/4);
        g2.drawLine(newWidth/6+1,newHeight*3/4+4,newWidth/6+7,newHeight*3/4);
        
	}
}
